package com.bwie.es.config;

import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: day20k-6.12
 * @BelongsPackage: com.bwie.es.conifg
 * @Author: LiFan
 * @CreateTime: 2023-06-12  14:33
 * @Description: //TODO
 * @Version: 1.0
 */
@Configuration
@ConfigurationProperties(prefix = "es")
@Data
@Log4j2
public class InitEsRestHighLevelClient {
    private String host;
    private Integer port;
    private String scheme;

    @Bean
    public RestHighLevelClient RestHighLevelClient() {
        return new RestHighLevelClient(
                RestClient.builder(new HttpHost(host,port,scheme))
        );
    }
}
